import page
from base.base import Base
import time

class PageAxaWriteInfo(Base):

    # 输入行驶证发证日期
    def page_input_runCardCertificateDate(self, runCardCertificateDate):
        try:
            # 删除readonly属性
            script = 'document.getElementById("runCardCertificateDate").removeAttribute("readonly")'
            # 执行JavaScript脚本
            self.driver.execute_script(script)  # 这一步执行后日期就能手动编辑了
            self.base_input(page.axa_runCardCertificateDate, runCardCertificateDate)
        except:
            pass

    # 输入车架号
    def page_input_vehicleFrameNo(self, vehicleFrameNo):
        self.base_input(page.axa_vehicleFrameNo, vehicleFrameNo)

    # 输入发动机号
    def page_input_engineNo(self, engineNo):
        self.base_input(page.axa_engineNo, engineNo)

    # 点击品牌型号
    def page_click_familyName_element(self):
        self.base_click_familyName(page.axa_familyName)

    # 输入注册登记日期
    def page_input_firstRegisterDate(self, firstRegisterDate):
        self.base_input(page.axa_firstRegisterDate, firstRegisterDate)

    # 输入车主证件号
    def page_input_showFormatCertificateNo(self, showFormatCertificateNo):
        self.base_input(page.axa_showFormatCertificateNo, showFormatCertificateNo)

    # 输入车主 手机号
    def page_input_showFormatTelephone(self, showFormatTelephone):
        self.base_input(page.axa_showFormatTelephone, showFormatTelephone)

    # 点击立即报价
    def page_click_validateFormLink(self):
        self.base_click(page.axa_validateFormLink)

    # 获取保费计算文本
    def page_get_text(self):
        return self.base_get_text(page.axa_baofeiTable)


    # 组合填写信息 业务
    def page_axa_write_info(self, runCardCertificateDate, vehicleFrameNo, engineNo,
                            firstRegisterDate, showFormatCertificateNo, showFormatTelephone):
        # frame = self.base_find(page.axa_iframe)
        # self.driver.switch_to.frame(frame)
        self.page_input_vehicleFrameNo(vehicleFrameNo)
        self.page_input_engineNo(engineNo)
        self.page_click_familyName_element()
        self.page_input_firstRegisterDate(firstRegisterDate)
        self.page_input_showFormatCertificateNo(showFormatCertificateNo)
        self.page_input_showFormatTelephone(showFormatTelephone)
        self.page_input_runCardCertificateDate(runCardCertificateDate)
        self.page_click_validateFormLink()
        time.sleep(10)


